<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>

<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Peeker Class</title>

<style type='text/css' media='all'>@import url('./userguide.css');</style>
<link rel='stylesheet' type='text/css' media='all' href='../userguide.css' />

<meta http-equiv='expires' content='-1' />
<meta http-equiv= 'pragma' content='no-cache' />
<meta name='robots' content='all' />

</head>
<body>

<!-- START NAVIGATION -->
<div id="nav"><div id="nav_inner"></div></div>
<div id="nav2"><a name="top">&nbsp;</a></div>
<div id="masthead">
<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
<tr>
<td><h1>Peeker</h1></td>
<td id="breadcrumb_right"></td>
</tr>
</table>
</div>
<!-- END NAVIGATION -->


<!-- START BREADCRUMB -->
<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
<tr>
<td id="breadcrumb">
<a href="https://github.com/sophistry/peeker">Project Home</a> &nbsp;&#8250;&nbsp;
<a href="peeker_toc.html">User Guide Home</a> &nbsp;&#8250;&nbsp;
Peeker Class
</td>
</tr>
</table>
<!-- END BREADCRUMB -->

<br clear="all" />


<!-- START CONTENT -->
<div id="content">


<h1>Peeker Detector Set Class</h1>

<p>This is the interface from the main Peeker Class to the Detectors.</p> 

<p>The Peeker Detector system lets you pull and process email in a <a href="http://en.wikipedia.org/wiki/Declarative_programming">declarative programming</a> style. This style can make logic clearer than a bunch of nested if statements. It also helps you modularize reuseable detector components. Declarative programming can help you split tasks among multiple programmers.</p>
<p class="important">Note: The Peeker Detector system only works if you use the get_message() function or create a custom message class and tell Peeker to use that class: <code>$this->peeker->set_message_class('peeker_header');</code></p>

<h3>Detector array</h3>

<p>This class holds an array of detectors.</p> 

<h2>Function Reference</h2>


<h3>make_detector($detector_method, $detector_method_arguments, $callback_method, $callback_method_arguments)</h3>

<p>Create a detector circuit that "detects" an event and triggers a callback when the event is TRUE. Returns the detector object when created.</p>
<code>// in_from is a custom message class method<br />
// that tests the from address with the strpos() function <br />
$detector_method = 'in_from';<br /> 
$detector_method_arguments = 'spammer@spamtown.us';<br /> <br />
// set_delete is a method in the custom header class<br />
$callback_method = 'set_delete';<br /> 
$callback_method_arguments = TRUE;<br /><br />
$detector = $this->peeker->make_detector_set();<br /> 
$detector->make_detector($detector_method, $detector_method_arguments, $callback_method, $callback_method_arguments);</code>

<p>Once you have a detector_set object you can add detectors. The detector set and its detectors must be created before calling the message() method.</p>

<h2>A note on detector method naming and the not__ string invertor</h2>

<p>Detector methods are functions that return TRUE or FALSE. Instead of writing the negated form of every function ( for instance, in_from() and not_in_from() ) this detector set class defines a string that will tell the detector to automatically 'NOT' the returned value. So instead of writing an actual "not_in_from()" function and bloating the class you can just pass the function name as 'not__in_from' (note double-underscore).</p>
<p>The not__ string can be used on any detector method (any method that returns a boolean). The return value of that function will be inverted.</p>

<code>// strpos_from is a custom message class method<br />
// that tests the from address with the strpos() function <br />
$detector_method = 'not__in_from'; // using the not__ invertor string<br /> 
$detector_method_arguments = 'secretaddress@mywordpresssite.us';<br /> <br />
// set_delete is a method in the custom header class<br />
$callback_method = 'set_delete';<br /> 
$callback_method_arguments = TRUE;<br /><br />
$detector = $this->peeker->make_detector_set();<br /> 
$detector->make_detector($detector_method, $detector_method_arguments, $callback_method, $callback_method_arguments);</code>

</div>
<!-- END CONTENT -->


<div id="footer">
<p>

<a href="#top">Top of Page</a>&nbsp;&nbsp;&nbsp;&middot;&nbsp;&nbsp;
<a href="peeker_toc.html">User Guide Home</a>
</p>
<p><a href="https://github.com/sophistry/peeker">Peeker</a> &nbsp;&middot;&nbsp; Copyright &#169; 2009-20xx &nbsp;&middot;&nbsp;</p>
</div>

</body>
</html>